package com.lovely3x.library.benas;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * 分享内容
 * Created by lovely3x on 16/8/26.
 */
public class ShareContent implements Parcelable {

    /**
     * 分享的标题
     */
    public String mTitle;

    /**
     * 分享的链接
     */
    public String mTargetUrl;

    /**
     * 分享的内容
     */
    public String mText;

    /**
     * 分享的图片的地址
     */
    public String imageUrl;

    /**
     * 分享的图片的drawable资源
     */
    public int imageResource;

    /**
     * 分享的位图
     * 不应该过大
     */
    public Bitmap bitmap;

    /**
     * 分享的图片的文件路径
     */
    public String imageFilePath;

    public ShareContent(String mTitle, String mTargetUrl, String mText, String imageUrl) {
        this.mTitle = mTitle;
        this.mTargetUrl = mTargetUrl;
        this.mText = mText;
        this.imageUrl = imageUrl;
    }

    public ShareContent() {
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.mTitle);
        dest.writeString(this.mTargetUrl);
        dest.writeString(this.mText);
        dest.writeString(this.imageUrl);
        dest.writeInt(this.imageResource);
        dest.writeParcelable(this.bitmap, flags);
        dest.writeString(this.imageFilePath);
    }

    protected ShareContent(Parcel in) {
        this.mTitle = in.readString();
        this.mTargetUrl = in.readString();
        this.mText = in.readString();
        this.imageUrl = in.readString();
        this.imageResource = in.readInt();
        this.bitmap = in.readParcelable(Bitmap.class.getClassLoader());
        this.imageFilePath = in.readString();
    }

    public static final Creator<ShareContent> CREATOR = new Creator<ShareContent>() {
        @Override
        public ShareContent createFromParcel(Parcel source) {
            return new ShareContent(source);
        }

        @Override
        public ShareContent[] newArray(int size) {
            return new ShareContent[size];
        }
    };
}
